const { app, BrowserWindow, screen } = require("electron");
const { join, resolve } = require("path");
let main_window = null;
const create_window = () => {
  // 获取窗口的可视区域 let { width, height } = screen.getPrimaryDisplay().workAreaSize;
  /* let { width, height } = screen.getPrimaryDisplay().workAreaSize;
  console.log(width, height); */
  main_window = new BrowserWindow({
    "fullscreen": true,
    "frame": false,
    "useContentSize": true,
    "center": true,
    // 窗口置顶了
    // "alwaysOnTop": true,
    // 禁止用户改变窗口的大小
    "resizable": false,
    // 背景透明了
    "transparent": true,
    "webPreferences": {
      "preload": resolve(__dirname, "index", "index.js"),
      "nodeIntegration": true,
      // 在外部引入的js中获取不到remote, 在main.js中也获取不到remote模块
      "enableRemoteModule": true,
      "contextIsolation": false
    }
  });
  process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = true;
  // 忽略所有鼠标点击事件
  main_window.setIgnoreMouseEvents(true);
  // main_window.webContents.openDevTools();
  main_window.loadFile("./index/index.html");
};
app.whenReady().then(() => {
  create_window();
  app.on("activate", () => {
    if (BrowserWindow.getAllWindows().length === 0) create_window();
  });
});
app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit();
    main_window = null;
  };
});